<script setup>
import { ref, computed } from 'vue'

const inputValue = ref('')
const reversed = computed(() => {
  return inputValue.value.split("").reverse().join("") || ''
})
const reversedValue = ref('')
const res = reversed => {
  reversedValue.value = reversed
}
</script>

<template>
  <div>
    <input type="text" v-model="inputValue">
    <button @click="res(reversed)">反转</button>
    <p>反转后的文本: {{ reversedValue }}</p>
  </div>
</template>

<style scoped>
</style>